package com.wangcang.widgetlibrary.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.wangcang.widgetlibrary.R;
import com.wangcang.widgetlibrary.bubble.PopUpUtils;
import com.wangcang.widgetlibrary.popupwindow.EasyPopupWindow;

/**
 * PopupWindow Demo
 * Created by ShineF on 2017/6/16 0016.
 */

public class PopupWindowActivity extends AppCompatActivity implements EasyPopupWindow.ChildClickListener, View.OnClickListener {

    private Button mBtnContent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo_popupwindow_layout);
        mBtnContent = (Button) findViewById(R.id.content);
    }

    public void showPop(View view) {
        PopUpUtils.showPopUpBottom(R.layout.view_easy_popupwindow, this, mBtnContent, true, this);
    }

    @Override
    public void getChildView(int layoutId, View view) {
        RelativeLayout tackPhotos = (RelativeLayout) view.findViewById(R.id.btn_tack_photo);
        Button photos = (Button) view.findViewById(R.id.btn_photos);
        Button cancel = (Button) view.findViewById(R.id.btn_cancel);
        tackPhotos.setOnClickListener(this);
        photos.setOnClickListener(this);
        cancel.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.btn_tack_photo) {
            Toast.makeText(PopupWindowActivity.this, "btn_tack_photo", Toast.LENGTH_SHORT).show();

        } else if (i == R.id.btn_photos) {
            Toast.makeText(PopupWindowActivity.this, "btn_photos", Toast.LENGTH_SHORT).show();

        } else if (i == R.id.btn_cancel) {
            Toast.makeText(PopupWindowActivity.this, "btn_cancel", Toast.LENGTH_SHORT).show();

        }
    }
}
